<include file="Public:header" />
<body>
<div class="main" >
	<div id="navigation"> &nbsp;当前位置 > 内容管理 > 评论管理</div>
	<div class="mainmenu">
		<a href="javascript:doAudit('{$vo.id}')">审 核</a>&nbsp;<a href="javascript:del('{$vo.id}')">删 除</a>&nbsp;&nbsp;
		内容模型：
		<select name="type" id="type">
					<volist name="models" id="vo">	
						<option value="{$vo.tablename}" <?php echo $type==$vo['tablename']?'selected="selected"':''; ?> >{$vo.name}</option>
					</volist>
		</select>
	</div>
	<table id="maintable">
		<tr>
			<th><input id="check" onclick="selectAll('sel','checkList');" type="checkbox" name="sel"></th><th>编号</th><th>发布者</th><th>评论时间</th><th>状态</th><th>评论内容</th><th>操 作</th>
		</tr>
		<volist name="list" id="vo">
			<tr>
			 <td><input name="checkList[]" value="{$vo.id}" type="checkbox"></td>
			 <td>{$vo.id}</td>
			 <td>{$vo.name}</td>
			 <td>{$vo.ctime|date="Y-m-d",###}</td>
			 <td><?php if($vo['status']==0){echo '未审核';}else{echo '已审核';}?></td>
			 <td>{$vo.comment}</td>
			 <td>
			 	 <a href="javascript:doAudit('{$vo.id}')"><img src="../Public/images/allow.gif" title="审核"/></a>&nbsp;&nbsp;
			 	 <a href="javascript:del('{$vo.id}')"><img src="../Public/images/b_drop.png"  title="删除"/></a>
			 </td>
		  </tr>
	  </volist>
		
  </table>
  <div class="mainmenu">{$page}</div>
</div>
<script type="text/javascript">
	$(
	 function(){
			$("#type").change(
				function(){
					var typeval =  $("#type").val();
					window.location.href="__URL__/commentList/type/"+typeval;
				}
			
			);
		}
	);
	function doAudit(id){
	var keyValue;
	if (id)
	{
		keyValue = id;
	}else {
		keyValue = getSelectCheckboxValues();
	}
	
	if (!keyValue)
	{
		alert('请选择要操作的对象！');
		return;
	}else{
		location.href = "__URL__/doAudit/id/"+keyValue;
	}
	
	
}


function del(id){
	var keyValue;
	if (id)
	{
		keyValue = id;
	}else {
		keyValue = getSelectCheckboxValues();
	}
	if (!keyValue)
	{
		alert('请选择删除项！');
		return;
	}

	if (window.confirm('确实要删除选择项吗？'))
	{	
		
		location.href = "__URL__/delete/id/"+keyValue;
	}
}

function getSelectCheckboxValues(){
	var obj = document.getElementsByName('checkList[]');
	var result ='';
	for (var i=0;i<obj.length;i++)
	{
		if (obj[i].checked==true)
				result += obj[i].value+",";

	}
	
	return result.substring(0, result.length-1);
}

 function selectAll(name,selectdName){


    	if($("input[name='"+name+"']").attr('checked')){

    		$("input[name='"+selectdName+"[]']").each(function(){
                $(this).attr('checked',true);
            });

    	}else{
    		$("input[name='"+selectdName+"[]']").each(function(){
                $(this).attr('checked',false);
            });

    	}
    }
</script>
</body>
</html>